<?php
/* @var $this PerguntaController */
/* @var $model Pergunta */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php $form=$this->beginWidget('CActiveForm', array(
                                                       'id'=>'pergunta-form',
                                                       // Please note: When you enable ajax validation, make sure the corresponding
                                                       // controller action is handling ajax validation correctly.
                                                       // There is a call to performAjaxValidation() commented in generated controller code.
                                                       // See class documentation of CActiveForm for details on this.
                                                       'enableAjaxValidation'=>false,
                                                  )); ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

    <div class="row-fluid">
        <?php echo $form->labelEx($model,'FORMULARIO_ID'); ?>
        <div class="input-append">
            <?php echo $form->dropDownList($model,'FORMULARIO_ID',Formulario::model()->getFormularioAll(),array('empty'=>'Selecione')); ?>
            <?php
            $this->widget('bootstrap.widgets.TbButton',array(
                                                            'label'=>'Add Item',
                                                            'type'=>'info',
                                                            'htmlOptions'=>array(
                                                                'data-toggle'=>'modal',
                                                                'data-target'=>'#myModal',
                                                            ),
                                                       )
            );
            ?>
        </div>
        <?php echo $form->error($model,'FORMULARIO_ID'); ?>
    </div>

    <div class="row-fluid">
        <div class="span4 leftnomargin">
            <?php echo $form->labelEx($model,'TITULO'); ?>
            <?php echo $form->textField($model,'TITULO',array('size'=>60,'maxlength'=>255,'class'=>'span12')); ?>
            <?php echo $form->error($model,'TITULO'); ?>
        </div>
        <div class="span2">
            <?php echo $form->labelEx($model,'OBRIGATORIO'); ?>
            <?php echo $form->checkBox($model,'OBRIGATORIO'); ?>
            <?php echo $form->error($model,'OBRIGATORIO'); ?>
        </div>
    </div>

    <div class="row-fluid">
        <?php echo $form->labelEx($model,'OBSERVACAO'); ?>
        <?php echo $form->textField($model,'OBSERVACAO',array('size'=>60,'maxlength'=>255)); ?>
        <?php echo $form->error($model,'OBSERVACAO'); ?>
    </div>

    <div class="row-fluid">
        <?php echo $form->labelEx($model,'ORDEM'); ?>
        <?php echo $form->NumberField($model,'ORDEM',array('min'=>'0')); ?>
        <?php echo $form->error($model,'ORDEM'); ?>
    </div>

    <div class="row-fluid">
        <?php echo $form->labelEx($model,'TIPO_ID'); ?>
        <?php echo $form->dropDownList($model,'TIPO_ID',Tipo::model()->getTipoAll(),array('empty'=>'Selecione','onchange'=>'showAddItem()')); ?>
        <?php echo $form->error($model,'TIPO_ID'); ?>
    </div>

    <div class="item-escala hide">
        <?php echo CHtml::label('Escala','Escala');?>
        <select name="Item[ESCALA_INICIO]" id="Item_ESCALA_INCIO" class="span1">
            <option <?php echo isset($model->itens[0]['INICIO_ESCALA']) && $model->itens[0]['INICIO_ESCALA']==0? 'selected="selected"':'' ?> value="0">0</option>
            <option <?php echo isset($model->itens[0]['INICIO_ESCALA']) && $model->itens[0]['INICIO_ESCALA']==1? 'selected="selected"':'' ?> value="1">1</option>
        </select>
        a
        <select name="Item[ESCALA_FIM]" id="Item_ESCALA_FIM" class="span1">
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==2? 'selected="selected"':'' ?> value="2">2</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==3? 'selected="selected"':'' ?> value="3">3</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==4? 'selected="selected"':'' ?> value="4">4</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==5? 'selected="selected"':'' ?> value="5">5</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==6? 'selected="selected"':'' ?> value="6">6</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==7? 'selected="selected"':'' ?> value="7">7</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==8? 'selected="selected"':'' ?> value="8">8</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==9? 'selected="selected"':'' ?> value="9">9</option>
            <option <?php echo isset($model->itens[0]['FIM_ESCALA']) && $model->itens[0]['FIM_ESCALA']==10? 'selected="selected"':'' ?> value="10">10</option>
        </select>
    </div>

    <div class="row-fluid" >
        <?php echo CHtml::label('Itens','itens');?>
        <ul class="unstyled">
            <?php echo $this->renderPartial('_listaItens',array('model'=>$model));?>
        </ul>
    </div>

    <div class="row-fluid">
        <?php echo $form->labelEx($model,'STATUS'); ?>
        <?php echo $form->checkBox($model,'STATUS'); ?>
        <?php echo $form->error($model,'STATUS'); ?>
    </div>

    <div class="row-fluid buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->
<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'myModal')); ?>
<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4>Modal header</h4>
</div>
<div class="modal-body">
</div>
<?php $this->endWidget(); ?>
<script type="text/javascript">
    /*<![CDATA[*/
    $(document).ready(function(){
        onLoadTipo();
    })
    /*]]>*/
</script>